import React from "react";
import {Button} from "antd";
import {Consumer} from "../../theme";
import './index.less';
import {WeaLocaleProvider} from "ecCom";

const getLabel = WeaLocaleProvider.getLabel;

export default class FBFooterView extends React.Component {
  render() {
    const { data, onSubmit, loading, disable, ...props } = this.props;
    const { btnText } = data;

    return (
      <Consumer>
        {({submitBtn}) => (
          <div className='wev-edc-form-footer__view' {...props} style={{textAlign: submitBtn && submitBtn.textAlign || 'left'}}>
            <Button
              type='primary'
              icon={(loading && !disable) && 'loading'}
              className={(loading || disable) && 'wea-edc-form-btn btn-disable' || 'wea-edc-form-btn'}
              onClick={onSubmit}
              style={ submitBtn && submitBtn.css || {} }
            >
              {btnText}
            </Button>
          </div>
        )}
      </Consumer>
    );
  }
}

FBFooterView.defaultProps = {
  data: {
  	btnText: getLabel('502502', '提交')
  },
  onSubmit: () => { }
};